<!DOCTYPE html>
<html>
<head>
	<title>video视频分享</title>
	<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=2.0, minimum-scale=1.0, user-scalable=no" />
    <meta name="format-detection" content="telephone=no"/>
    <meta name="viewport" content="width=320,maximum-scale=1.3,user-scalable=no">
    <script type="text/javascript" src="http://res.wx.qq.com/open/js/jweixin-1.2.0.js"></script>
    <script src="https://code.jquery.com/jquery-3.0.0.min.js"></script>
	<link href="https://cdn.bootcss.com/weui/1.0.2/style/weui.min.css" rel="stylesheet">
	<script src="https://cdn.bootcss.com/jquery/3.2.1/jquery.min.js"></script>
	<script src="https://cdn.bootcss.com/jquery-cookie/1.4.1/jquery.cookie.js"></script>
	<script src="https://cdn.bootcss.com/zepto/1.2.0/zepto.min.js"></script>
	<script src="https://imgcache.qq.com/tencentvideo_v1/tvp/js/tvp.player_v2_zepto.js" charset="utf-8"></script>
	<script src="https://v.qq.com/iframe/tvp.config.js" charset="utf-8"></script>
	<script src="http://qzs.qq.com/tencentvideo_v1/js/tvp/tvp.player.js" charset="utf-8"></script>
	<script src="https://cdn.bootcss.com/zepto/1.2.0/zepto.min.js"></script>
<script src="https://imgcache.qq.com/tencentvideo_v1/tvp/js/tvp.player_v2_zepto.js" charset="utf-8"></script>

</head>
<style type="text/css">
	body{padding: 0;border:0;background: #F0F0F0;}
	.page{background:white;padding: 10px}
	.read{font-size: 14px;margin-bottom: 8px;}
	.div1{color: #8c8c8c;}
</style>
<body>
    <div class="page">
	    	<div class="page__hd">    		
	    		<p class="page__desc" style="font-style: normal;font-family:Microsoft Yahei;font-weight:400;">《洛克王国  圣龙的心愿》1月31号震撼上映 席卷全球......</p>	
	    	</div>	     	
	     	<!-- 日期和昵称 -->
	     	<div class="page__bd">
	     		<article class="weui-article">
	     			<section>
	     				<h3 id="div1" style="color:#8c8c8c;font-size: 14px;margin-left: -17px;margin-top: -13px;"></h3>
	     				<h3 style="color:#607fa6;margin-left: 70px;margin-top: -30px;font-size: 16px;">woshixiaokeai</h3>
	     			</section>
     		    </article>
	     	</div>
	     	<!-- 视频 -->
	     	<div class="weui-flex__item" style="margin-top: -25px;">
	     	    <div class="video" id="movies" style="width:100%;height:169px;margin-bottom: 15px;"></div>
	     	</div>    	
	     	<!-- 阅读全文，阅读量，点赞数 -->
	     	<div class="read">
	     		<span style="color:#607fa6;">阅读全文</span>&nbsp;
	     		<span class="div1">阅读1w+</span>&nbsp;
	     		<span class="div1">
	     			<i class="islike" style="position: relative;top: 1px;margin-right: 3px;background: transparent url() no-repeat;width: 13px;height: 13px;display: inline-block;-webkit-background-size: 100% auto;background-size: 100% auto;">	     				
	     			</i>
	     			<span id="like">4596</span>
	     		</span>
	     	</div>
	     	<input type="hidden" value="0" id="num">
	     	<!-- 记录分享给朋友的次数 -->
	     	<input type="hidden" value="0" id="fnum">
	     	<!-- 记录分享到朋友圈的次数 -->
	     	<!-- 分享指示层图片 -->
		    <img src="http://puep.qpic.cn/coral/Q3auHgzwzM4fgQ41VTF2rEziaMPy9eo2rCE0LZUcuW5ic0kAcicZeytag/0"  id="share" style="display:block;width:100%;position:fixed;z-index:999;top:0;left:0;display:none">
    </div>
    <!-- 广告 -->
    <div style="border-bottom: 1px dotted #e1e1e1;margin: 0px 15px 20px;text-align: center;line-height: 22px;">
    <span style="position: relative;top: 10px;color: #868686;font-size: 15px;padding: 0 8px">广告</span>
    </div>
    <div class="weui-panel weui-panel_access">
     	<div class="weui-panel__bd">
     		<!-- 例子 -->
     		<a href="javascript:void(0);" class="weui-media-box weui-media-box_appmsg">
                <img src="http://mj.weimob.com/img/pub_adv_03.png" border="0" style="width: 100%;">
            </a>
     	</div>
     </div>    
</body> 
<script type="text/javascript"> 
          var datas = new Date();
          var date = datas.getFullYear()+'-'+(parseInt(datas.getMonth())+1)+'-'+datas.getDate();
          $("#div1").text(date);	
	  	  var int = 0;//用来停住计时器	 
	  	  //实现微信分享接口配置文件   
	      wx.config({
	        appId:'<?=$data["appId"]?>',
	        timestamp:'<?=$data["timestamp"]?>',
	        nonceStr: '<?=$data["nonceStr"]?>',
	        signature: '<?=$data["signature"]?>',
		    jsApiList: [
		       'onMenuShareTimeline',
		       'onMenuShareAppMessage',
		       'hideMenuItems'
		    ]
	      });
	       wx.ready(function () {
	             //分享到朋友圈
	            wx.onMenuShareTimeline({
	                    title:'洛克王国  圣龙的心愿》1月31号震撼上映......',
	                    link:'http://tt.t.vipds.cn/check',
	                    imgUrl:'https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1516359160158&di=3a39c3d3d72eb7b87b3544fd5e3c8881&imgtype=0&src=http%3A%2F%2Fossweb-img.qq.com%2Fimages%2Froco%2Fplay2013%2Fpic1.jpg',	                   
	                    success:function(){  
	                        var numss = $("#num").val();//只有分享给朋友的次数大于3时才可分享到朋友圈
							if(numss>=3){//记录已经分享到朋友圈
				                var fshsnum = parseInt($("#fnum").val()) + 1;
				                $("#fnum").val(fshsnum);
				                int = 0;//分享到朋友圈之后把int再次设为0，只触发一次计时器
				            }                  
	                    },
	                    cancel:function(){ 
	                    }
	            });
              //分享给朋友
	            wx.onMenuShareAppMessage({
	                    title:'洛克王国  圣龙的心愿》1月31号震撼上映......',
	                    desc:'test',
	                    link:'http://tt.t.vipds.cn/check',
	                    imgUrl:'https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1516359160158&di=3a39c3d3d72eb7b87b3544fd5e3c8881&imgtype=0&src=http%3A%2F%2Fossweb-img.qq.com%2Fimages%2Froco%2Fplay2013%2Fpic1.jpg',
	                    type:'',
	                    dateUrl:'http://media.html5media.info/video.mp4',// 如果type是music或video，则要提供数据链接，默认为空
	                    success:function(){
	                    	var shsnum = parseInt($("#num").val())+1;
	                    	$("#num").val(shsnum);
	                    	int = 0;//每次分享到朋友时都设为0，为了程序更好的走下去
	                    },
	                    cancel:function(){
	                    }
	            });
	            //批量隐藏按钮，只能隐藏传播类、保护类
	            wx.hideMenuItems({
					menuList: [
						'menuItem:share:qq',
						'menuItem:share:weiboApp',
						'menuItem:favorite',
						'menuItem:share:facebook',
						'menuItem:share:QZone',
						'menuItem:editTag',
						'menuItem:delete',
						'menuItem:copyUrl',
						'menuItem:originPage',
						'menuItem:readMode',
						'menuItem:openWithQQBrowser',
						'menuItem:openWithSafari',
						'menuItem:share:email',
						'menuItem:share:brand'
					]
			    });  
        }); 
	    //腾讯视频插件(腾讯视频插件api)
	    var video = new tvp.VideoInfo();  
	    video.setVid("q0011iyvdam");//视频vid  
	    var player = new tvp.Player(300, 169);//视频高宽  
	    player.create({
		   html5VodUIFeature:["controlbar", "tips", "title", "meta", "playpause", "progress", "timepanel", "definition", "volume", "overlay", "bigben", "posterlayer", "shadow", "promotion", "loadingAd", "adonend", "bullet", "preview", "verticalbullet"],
	    });
	    player.setCurVideo(video);  
	    player.addParam("autoplay","0");//是否自动播放，1为自动播放，0为不自动播放  
	    player.addParam("wmode","opaque");  
	    player.addParam("showend",0);  
	    player.addParam("adplay",0);    
	    player.addParam("wmode","transparent");  
	    player.addParam("pic","http://ossweb-img.qq.com/images/roco/act/a20120925movie/video_pic.jpg");//默认图片地址  
	    player.addParam("flashskin", "http://imgcache.qq.com/minivideo_v1/vd/res/skins/TencentPlayerMiniSkin.swf");//是否调用精简皮肤，不使用则删掉此行代码  
	    player.write("movies");  //id="movies"

        //视频截取 计时器      
	    function authtime(){
	      // localStorage.clear();
	      var result = player.getDuration();
	      var time = Math.floor(result)/2;//要中止的时间秒数，视频时长的一半	        
			if(localStorage.getItem('curr')){
				currentTime = localStorage.getItem('curr');
			}else{
				currentTime = player.getCurTime();
			}	
			var curr = currentTime;//返回音频/视频播放的当前位置（以秒计）        
			var nums = $("#num").val();
			var fnums= $("#fnum").val();
			if (localStorage.getItem('nums')) {
				$("#num").val(localStorage.getItem('nums'));
				$("#fnum").val(localStorage.getItem('fnums'));
			}
			if (time != ""){
				if (curr >= time) {
		            player.pause();//pause() 方法停止（暂停）当前播放的音频或视频
			        if(int < 1){	
			            if((nums == 0) && (fnums == 0)){
			            	    setnum(nums,fnums,curr);
			            	    //安卓手机显示全屏不能弹出微信提示框，利用再一次刷新（影响效率）
			            	    var refresh = 1;
			            	    if (!localStorage.getItem('refresh')) {
			            	    	localStorage.setItem('refresh',refresh);
			            	    	location.href = 'http://tt.t.vipds.cn/videoshow/test';
			            	    }
								dialog('请分享到<span style="font-size: 30px;color: #f5294c">3</span>个不同的群观看！', '好');
								$("#share").show();
							}else if((nums == 1) && (fnums == 0)){
								setnum(nums,fnums,curr);
								dialog('分享成功,请继续分享到<span style="font-size: 30px;color: #f5294c">2</span>个不同的群观看！', '好');
								$("#share").show();
							}else if((nums == 2) && (fnums == 0)){
								setnum(nums,fnums,curr);
								dialog('分享成功,请继续分享到<span style="font-size: 30px;color: #f5294c">1</span>个不同的群观看！', '好');
								$("#share").show();
							}else if((nums >= 3) && (fnums == 0)){
								var ffnums = 1;
								setnum(nums,fnums,curr,ffnums);
								dialog('分享成功,最后请分享到<span style="font-size: 30px;color: #f5294c">朋友圈</span>观看完整视频！', '好');
								$("#share").show();
							}else if((nums >= 3) && (fnums > 0)){
								localStorage.removeItem('curr');
								if (localStorage.getItem('ffnums')) {
									localStorage.removeItem('ffnums');
									setnum(nums,fnums);
									dialog('分享成功,点击确定观看！', '确定',function(){
										clearInterval(settime);//清除定时器
										player.play();
										$("#share").hide();
								    });
								}else{
									clearInterval(settime);
									player.play();
								}								
							}                  
		                    int  = int + 1;//分享完成之后+1，给出条件int<1,所以计时器不会触发
			            }	            
	     	        }
				}	        
		    }
        var settime = setInterval("authtime()",10);//触发计时器
        //记录点击的次数
        var clickNumber = 0;
        $(".islike").click(function(){
        	if (clickNumber%2==0) {
        		var likes = parseInt($("#like").text())+1;
        	    $("#like").text(likes);
        	}else{
                var like = parseInt($("#like").text())-1;
        	    $("#like").text(like);
        	}  
        	clickNumber++;         
        }); 		
		//微信弹出提示框
		function dialog(title, msg, callback){
	        var dialog1, dialog2,dialog3,dialog4;
	        dialog1 = '\
	           <div class="weui-dialog_confirm" id="dialog1" style="display: none;">\
	              <div class="weui-mask"></div>\
	              <div class="weui-dialog">\
	                  <div class="weui-dialog_hd"><strong class="weui-dialog_title">' + title + '</strong></div>\
	                  <div class="weui-dialog_ft">\
	                      <a href="javascript:;" class="weui-dialog__btn weui-dialog__btn_primary" id="tanchuang">'+msg+'</a>\
	                  </div>\
	              </div>\
	           </div>\
	        ';
	        dialog2 = '\
	           <div class="weui-dialog_confirm" id="dialog2" style="display: none;">\
	              <div class="weui-mask"></div>\
	              <div class="weui-dialog">\
	                  <div class="weui-dialog_hd"><strong class="weui-dialog_title">' + title + '</strong></div>\
	                  <div class="weui-dialog_ft">\
	                      <a href="javascript:;" class="weui-dialog__btn weui-dialog__btn_primary" id="tanchuang2">'+msg+'</a>\
	                  </div>\
	              </div>\
	           </div>\
	        ';
            dialog3 = '\
	        	<div class="js_dialog" id="iosDialog1" style="display: none;">\
	            	<div class="weui-mask"></div>\
	            	<div class="weui-dialog">\
	                	<div class="weui-dialog__bd">' + title + '</div>\
	                	<div class="weui-dialog__ft">\
	                    	<a href="javascript:;" class="weui-dialog__btn weui-dialog__btn_primary">' + msg + '</a>\
	                	</div>\
	            	</div>\
	        	</div>\
            ';
            dialog4 = '\
        	<div class="js_dialog" id="iosDialog2" style="display: none;">\
            	<div class="weui-mask"></div>\
            	<div class="weui-dialog">\
                	<div class="weui-dialog__bd">' + title + '</div>\
                	<div class="weui-dialog__ft">\
                    	<a href="javascript:;" class="weui-dialog__btn weui-dialog__btn_primary">' + msg + '</a>\
                	</div>\
            	</div>\
        	</div>\
        	';
            var u = navigator.userAgent;
            //安卓和Linux系统
            if(u.indexOf('Android') > -1 || u.indexOf('Linux') > -1){
            	if(arguments[2]){
			           $('body').append(dialog1);
			           $('#dialog1').fadeIn('fast');
			           $('#dialog1 .weui-dialog__btn_primary').on('click',function(){callback();});
			           $('#dialog1 .weui-dialog__btn_primary').on('click',function(){
			               $('#dialog1').fadeOut('fast',function(){
			                  $('#dialog1').remove(); //移除所有#dialog1
			               });
			           });
	            }else{
			           if(!$('#dialog2').length){
			               $('body').append(dialog2);
			           }else{
			               $('#dialog2 .weui-dialog_title').html(title);
			               $('#dialog2 .weui-dialog_bd').html(msg);
			           }
			           $('#dialog2').fadeIn('fast');
			           $('#dialog2 .weui-dialog__btn_primary').on('click',function(){
			               $('#dialog2').fadeOut('fast');
			           });
		        }
            }else if(u.indexOf('iPhone') > -1){//苹果系统
            	if(arguments[2]){
			           $('body').append(dialog3);
			           $('#iosDialog1').fadeIn('fast');
			           $('#iosDialog1 .weui-dialog__btn_primary').on('click',function(){
			               callback();   
			           });
			           $('#iosDialog1 .weui-dialog__btn_primary').on('click',function(){
			               $('#iosDialog1').fadeOut('fast',function(){
			                  $('#iosDialog1').remove(); 
			               });
			           });
		        }else{			        	
			           if(!$('#iosDialog2').length){
			               $('body').append(dialog4);
			           }else{
			               $('#iosDialog2 .weui-dialog__bd').html(title);
			               $('#iosDialog2 .weui-dialog__btn_primary').html(msg);
			           }
			           $('#iosDialog2').fadeIn('fast');
			           $('#iosDialog2 .weui-dialog__btn_primary').on('click',function(){
			               $('#iosDialog2').fadeOut('fast');
			           });
       	 		}
            }	        
        }
	     $("#share").on('click',function(){
	     	 int = 0;
	     	 authtime();
	     }); 
	     //记录之前分享了几次
	     function setnum(nums,fnums,curr,ffnums){
	     	 if (curr) {
	     	 	localStorage.setItem('curr',curr);
	     	 }
	     	 localStorage.setItem('nums',nums);
	     	 localStorage.setItem('fnums',fnums);
	     	 if (ffnums) {
	     	 	localStorage.setItem('ffnums',ffnums);
	     	 }
	     }    
</script>
</html>